<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>数据库模式可视化</title>
    <!-- Material Design Lite CSS -->
    <link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
    <link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
    <script defer src="https://code.getmdl.io/1.3.0/material.min.js"></script>
    <style>
        body {
            font-family: 'Roboto', 'Helvetica', sans-serif;
            margin: 0;
            padding: 0;
            background-color: #f5f5f5;
        }
        .page-content {
            padding: 24px;
            max-width: 1200px;
            margin: 0 auto;
        }
        .mdl-card {
            width: 100%;
            min-height: auto;
            margin-bottom: 24px;
        }
        .mdl-card__title {
            background-color: #3f51b5;
            color: #fff;
            height: 64px;
        }
        .table-card {
            margin-bottom: 32px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }
        .table-header {
            background-color: #3f51b5;
            color: white;
            padding: 16px;
            border-radius: 4px 4px 0 0;
        }
        .table-content {
            padding: 16px;
            background-color: white;
        }
        .column-row {
            display: flex;
            border-bottom: 1px solid #e0e0e0;
            padding: 8px 0;
        }
        .column-row:last-child {
            border-bottom: none;
        }
        .column-name {
            flex: 2;
            font-weight: 500;
        }
        .column-type {
            flex: 2;
            color: #666;
        }
        .column-constraints {
            flex: 3;
            color: #666;
        }
        .primary-key {
            color: #ff4081;
            font-weight: 500;
        }
        .foreign-key {
            color: #2196F3;
            font-weight: 500;
        }
        .relationship-diagram {
            margin-top: 40px;
            padding: 20px;
            background-color: white;
            border-radius: 4px;
            box-shadow: 0 4px 8px rgba(0,0,0,0.2);
        }
        .relationship-title {
            margin-bottom: 20px;
            color: #3f51b5;
        }
        .relationship-container {
            display: flex;
            flex-wrap: wrap;
            justify-content: space-around;
        }
        .relationship-item {
            margin: 10px;
            padding: 15px;
            background-color: #e8eaf6;
            border-radius: 4px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
            max-width: 300px;
        }
        .relationship-arrow {
            font-size: 24px;
            margin: 0 10px;
            color: #3f51b5;
        }
        .table-description {
            margin-top: 8px;
            color: #666;
            font-style: italic;
        }
        .mdl-tabs__tab-bar {
            justify-content: flex-start;
        }
        .mdl-tabs__tab {
            flex-grow: 0;
        }
        .schema-overview {
            margin-bottom: 32px;
        }
        .schema-info {
            background-color: white;
            padding: 16px;
            border-radius: 4px;
            box-shadow: 0 2px 4px rgba(0,0,0,0.1);
        }
    </style>
</head>
<body>
    <div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
        <header class="mdl-layout__header">
            <div class="mdl-layout__header-row">
                <span class="mdl-layout-title">数据库模式可视化</span>
                <div class="mdl-layout-spacer"></div>
                <nav class="mdl-navigation mdl-layout--large-screen-only">
                    <a class="mdl-navigation__link" href="#overview">概览</a>
                    <a class="mdl-navigation__link" href="#tables">表</a>
                    <a class="mdl-navigation__link" href="#relationships">关系</a>
                </nav>
            </div>
        </header>
        <div class="mdl-layout__drawer">
            <span class="mdl-layout-title">导航</span>
            <nav class="mdl-navigation">
                <a class="mdl-navigation__link" href="#overview">概览</a>
                <a class="mdl-navigation__link" href="#tables">表</a>
                <a class="mdl-navigation__link" href="#relationships">关系</a>
            </nav>
        </div>
        <main class="mdl-layout__content">
            <div class="page-content">
                <section id="overview" class="schema-overview">
                    <h4>数据库概览</h4>
                    <div class="schema-info">
                        <p><strong>数据库名称:</strong> CityDesignServiceBaseOnGPT</p>
                        <p><strong>数据库类型:</strong> SQL Server</p>
                        <p><strong>描述:</strong> 该数据库使用ASP.NET Identity进行用户管理，并有自定义扩展。它包含用户、角色、声明、登录和令牌的标准Identity表。</p>
                        <p><strong>表总数:</strong> 7</p>
                    </div>
                </section>

                <section id="tables">
                    <h4>数据库表</h4>

                    <div class="mdl-tabs mdl-js-tabs mdl-js-ripple-effect">
                        <div class="mdl-tabs__tab-bar">
                            <a href="#users-panel" class="mdl-tabs__tab is-active">AspNetUsers</a>
                            <a href="#roles-panel" class="mdl-tabs__tab">AspNetRoles</a>
                            <a href="#user-roles-panel" class="mdl-tabs__tab">AspNetUserRoles</a>
                            <a href="#user-claims-panel" class="mdl-tabs__tab">AspNetUserClaims</a>
                            <a href="#role-claims-panel" class="mdl-tabs__tab">AspNetRoleClaims</a>
                            <a href="#user-logins-panel" class="mdl-tabs__tab">AspNetUserLogins</a>
                            <a href="#user-tokens-panel" class="mdl-tabs__tab">AspNetUserTokens</a>
                        </div>

                        <!-- AspNetUsers Table -->
                        <div class="mdl-tabs__panel is-active" id="users-panel">
                            <div class="table-card">
                                <div class="table-header">
                                    <h4>AspNetUsers</h4>
                                    <div class="table-description">存储用户信息，包括自定义的ShowName字段</div>
                                </div>
                                <div class="table-content">
                                    <div class="column-row">
                                        <div class="column-name">Id</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="primary-key">主键</span>, 自增(1,1)</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">UserName</div>
                                        <div class="column-type">nvarchar(256)</div>
                                        <div class="column-constraints">可为空</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">NormalizedUserName</div>
                                        <div class="column-type">nvarchar(256)</div>
                                        <div class="column-constraints">可为空, 已索引</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">Email</div>
                                        <div class="column-type">nvarchar(256)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">NormalizedEmail</div>
                                        <div class="column-type">nvarchar(256)</div>
                                        <div class="column-constraints">nullable, indexed</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">EmailConfirmed</div>
                                        <div class="column-type">bit</div>
                                        <div class="column-constraints">非空</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">PasswordHash</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">SecurityStamp</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ConcurrencyStamp</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">PhoneNumber</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">PhoneNumberConfirmed</div>
                                        <div class="column-type">bit</div>
                                        <div class="column-constraints">not null</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">TwoFactorEnabled</div>
                                        <div class="column-type">bit</div>
                                        <div class="column-constraints">not null</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">LockoutEnd</div>
                                        <div class="column-type">datetimeoffset</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">LockoutEnabled</div>
                                        <div class="column-type">bit</div>
                                        <div class="column-constraints">not null</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">AccessFailedCount</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints">not null</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ShowName</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">not null</div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- AspNetRoles Table -->
                        <div class="mdl-tabs__panel" id="roles-panel">
                            <div class="table-card">
                                <div class="table-header">
                                    <h4>AspNetRoles</h4>
                                    <div class="table-description">存储角色信息</div>
                                </div>
                                <div class="table-content">
                                    <div class="column-row">
                                        <div class="column-name">Id</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="primary-key">PRIMARY KEY</span>, Identity(1,1)</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">Name</div>
                                        <div class="column-type">nvarchar(256)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">NormalizedName</div>
                                        <div class="column-type">nvarchar(256)</div>
                                        <div class="column-constraints">nullable, indexed</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ConcurrencyStamp</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- AspNetUserRoles Table -->
                        <div class="mdl-tabs__panel" id="user-roles-panel">
                            <div class="table-card">
                                <div class="table-header">
                                    <h4>AspNetUserRoles</h4>
                                    <div class="table-description">映射用户到角色的关系（多对多关系）</div>
                                </div>
                                <div class="table-content">
                                    <div class="column-row">
                                        <div class="column-name">UserId</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="primary-key">主键</span>, <span class="foreign-key">外键</span> (AspNetUsers.Id)</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">RoleId</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="primary-key">主键</span>, <span class="foreign-key">外键</span> (AspNetRoles.Id)</div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- AspNetUserClaims Table -->
                        <div class="mdl-tabs__panel" id="user-claims-panel">
                            <div class="table-card">
                                <div class="table-header">
                                    <h4>AspNetUserClaims</h4>
                                    <div class="table-description">存储用户声明</div>
                                </div>
                                <div class="table-content">
                                    <div class="column-row">
                                        <div class="column-name">Id</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="primary-key">PRIMARY KEY</span>, Identity(1,1)</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">UserId</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="foreign-key">外键</span> (AspNetUsers.Id)</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ClaimType</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ClaimValue</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- AspNetRoleClaims Table -->
                        <div class="mdl-tabs__panel" id="role-claims-panel">
                            <div class="table-card">
                                <div class="table-header">
                                    <h4>AspNetRoleClaims</h4>
                                    <div class="table-description">存储角色声明</div>
                                </div>
                                <div class="table-content">
                                    <div class="column-row">
                                        <div class="column-name">Id</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="primary-key">PRIMARY KEY</span>, Identity(1,1)</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">RoleId</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="foreign-key">外键</span> (AspNetRoles.Id)</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ClaimType</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ClaimValue</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- AspNetUserLogins Table -->
                        <div class="mdl-tabs__panel" id="user-logins-panel">
                            <div class="table-card">
                                <div class="table-header">
                                    <h4>AspNetUserLogins</h4>
                                    <div class="table-description">存储用户的外部登录提供程序</div>
                                </div>
                                <div class="table-content">
                                    <div class="column-row">
                                        <div class="column-name">LoginProvider</div>
                                        <div class="column-type">nvarchar(450)</div>
                                        <div class="column-constraints"><span class="primary-key">主键</span></div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ProviderKey</div>
                                        <div class="column-type">nvarchar(450)</div>
                                        <div class="column-constraints"><span class="primary-key">PRIMARY KEY</span></div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">ProviderDisplayName</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">UserId</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="foreign-key">FOREIGN KEY</span> (AspNetUsers.Id)</div>
                                    </div>
                                </div>
                            </div>
                        </div>

                        <!-- AspNetUserTokens Table -->
                        <div class="mdl-tabs__panel" id="user-tokens-panel">
                            <div class="table-card">
                                <div class="table-header">
                                    <h4>AspNetUserTokens</h4>
                                    <div class="table-description">存储用户令牌（例如，用于密码重置）</div>
                                </div>
                                <div class="table-content">
                                    <div class="column-row">
                                        <div class="column-name">UserId</div>
                                        <div class="column-type">int</div>
                                        <div class="column-constraints"><span class="primary-key">PRIMARY KEY</span>, <span class="foreign-key">FOREIGN KEY</span> (AspNetUsers.Id)</div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">LoginProvider</div>
                                        <div class="column-type">nvarchar(450)</div>
                                        <div class="column-constraints"><span class="primary-key">PRIMARY KEY</span></div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">Name</div>
                                        <div class="column-type">nvarchar(450)</div>
                                        <div class="column-constraints"><span class="primary-key">PRIMARY KEY</span></div>
                                    </div>
                                    <div class="column-row">
                                        <div class="column-name">Value</div>
                                        <div class="column-type">nvarchar(max)</div>
                                        <div class="column-constraints">nullable</div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </section>

                <section id="relationships" class="relationship-diagram">
                    <h4 class="relationship-title">表关系</h4>

                    <div class="relationship-container">
                        <div class="relationship-item">
                            <strong>AspNetUsers</strong> <span class="relationship-arrow">→</span> <strong>AspNetUserClaims</strong>
                            <p>一对多：一个用户可以有多个声明</p>
                        </div>

                        <div class="relationship-item">
                            <strong>AspNetUsers</strong> <span class="relationship-arrow">↔</span> <strong>AspNetRoles</strong>
                            <p>多对多：用户可以有多个角色，角色可以有多个用户</p>
                            <p><em>通过：</em> AspNetUserRoles</p>
                        </div>

                        <div class="relationship-item">
                            <strong>AspNetRoles</strong> <span class="relationship-arrow">→</span> <strong>AspNetRoleClaims</strong>
                            <p>一对多：一个角色可以有多个声明</p>
                        </div>

                        <div class="relationship-item">
                            <strong>AspNetUsers</strong> <span class="relationship-arrow">→</span> <strong>AspNetUserLogins</strong>
                            <p>一对多：一个用户可以有多个外部登录</p>
                        </div>

                        <div class="relationship-item">
                            <strong>AspNetUsers</strong> <span class="relationship-arrow">→</span> <strong>AspNetUserTokens</strong>
                            <p>一对多：一个用户可以有多个令牌</p>
                        </div>
                    </div>
                </section>
            </div>
        </main>
    </div>
</body>
</html>
